<?php include('view/template/common/header.tpl'); ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('./view/image/country.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo "Lưu Lại"; ?></span></a><a onclick="location = '<?php echo $link_list; ?>';" class="button"><span><?php echo "Hủy"; ?></span></a></div>
  </div>
  <div class="content">
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <table class="form">


       <tr><td><?php echo ten; ?></td><td><input  type="text" name="ten" value="<?php echo $quangcao['ten']; ?>"/>
       <tr><td><?php echo link; ?></td><td><input type="text" name="link" value="<?php echo $quangcao['link']; ?>"/></td></tr>
       
      <tr>
			<td><?php echo file;?></td>
			<td>
	                <input id="xFilePath" name="file" type="text" size="60" value="<?php echo $quangcao['file']; ?>" />
		        <input type="button" value="Chọn ảnh" onclick="BrowseServer();" /> <br/>
                        <?php if($quangcao['file']) { ?>
                        <img src ="<?php echo $quangcao['file'];?>" width= "150" height ="112" class="bimg"/> 
                        <?php } else{?>
                        <img src ="./view/image/noimage.png" width= "150" height ="112" class="bimg"/> 
                        <?php } ?>
                         </td>
		</tr>

       <tr>
              <td><?php echo loai; ?></td>
              <td><select name="loai_id">
               <?php if($list_loaiquangcao) {?>
		        <?php foreach($list_loaiquangcao as $lqc) { ?>
                          <?php if($lqc['loai_id'] == $quangcao['loai_id'])  { ?> 
		          <option value="<?php echo $lqc['loai_id'];?>" selected="selected"><?php echo $lqc['ten_loai']; ?></option>
		        <?php } else { ?>
                        <option value="<?php echo $lqc['loai_id'];?>"><?php echo $lqc['ten_loai']; ?></option>
                        <?php } }?>
                 
                   <?php } ?>
                </select></td>
        </tr>
<!--
       <tr>
              <td><?php echo ben; ?></td>
              <td><select name="ben">
                  <?php if($quangcao['ben']=='t') { ?>
                  <option value="p" ><?php echo phai; ?></option>
                  <option value="t" selected="selected"><?php echo trai; ?></option>
                  <?php } else { ?>
                  <option value="p" selected="selected"><?php echo phai; ?></option>
                  <option value="t" ><?php echo trai; ?></option>
                  <?php } ?>
                </select></td>
        </tr>
-->
        <tr>
              <td><?php echo $trang_thai; ?></td>
              <td><select name="status">
                  <?php if($quangcao['status']=='0') { ?>
                  <option value="1" ><?php echo $active; ?></option>
                  <option value="0" selected="selected"><?php echo $deactive; ?></option>
                  <?php } else { ?>
                  <option value="1" selected="selected"><?php echo "$active"; ?></option>
                  <option value="0" ><?php echo "$deactive"; ?></option>
                  <?php } ?>
                </select></td>
        </tr>

   
        
        
	
      </table>
    </form>
  </div><div class="bottom_button"><a onclick="$('#form').submit();" class="button"><span><?php echo "Lưu Lại"; ?></span></a><a onclick="location = '<?php echo $link_list; ?>';" class="button"><span><?php echo "Hủy"; ?></span></a></div>
</div>
<?php include('view/template/common/footer.tpl'); ?>
<script type="text/javascript">
	 var editor = CKEDITOR.replace( 'motachitiet');
         var editor1 = CKEDITOR.replace( 'motachung',{
					toolbar :
					[
						[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','Image' ],
						[ 'UIColor' ], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl']
					]});
	 CKFinder.setupCKEditor( editor, './view/javascript/ckfinder/' ) ;
         CKFinder.setupCKEditor( editor1, './view/javascript/ckfinder/' ) ;
</script>

<script type="text/javascript">

function BrowseServer()
{
	// You can use the "CKFinder" class to render CKFinder in a page:
	var finder = new CKFinder();
	finder.basePath = './view/javascript/ckfinder/';	// The path for the installation of CKFinder (default = "/ckfinder/").
	finder.selectActionFunction = SetFileField;
	finder.popup();

	// It can also be done in a single line, calling the "static"
	// popup( basePath, width, height, selectFunction ) function:
	// CKFinder.popup( '../', null, null, SetFileField ) ;
	//
	// The "popup" function can also accept an object as the only argument.
	// CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
}

// This is a sample function which is called when a file is selected in CKFinder.
function SetFileField( fileUrl )
{
	document.getElementById( 'xFilePath' ).value = fileUrl;
}

</script>